<?php

/*
|--------------------------------------------------------------------------
| API Routes
|--------------------------------------------------------------------------
|
| Here is where you can register API routes for your application. These
| routes are loaded by the RouteServiceProvider within a group which
| is assigned the "api" middleware group. Enjoy building your API!
|
*/
// 易宝支付回调

Route::post('yeepay_pay_notify', 'YeepayController@payNotify');
// 易宝小微注册回调
Route::post('yeepay_micro_register_notify', 'YeepayController@microRegisterNotify');
// 易宝企业注册回调
Route::post('yeepay_enterprise_register_notify', 'YeepayController@enterpriseRegisterNotify');
// 易宝钱包注册
Route::post('yeepay_open_wallet_notify', 'YeepayController@openWalletNotify');

Route::get('checkWalletAddress', 'UserController@checkWalletAddress');

// AdaPay 异步回调
Route::post('adapay_notify', 'AdaPayController@notify');

//杉德支付回调
Route::any('sdpay_pay_notify', 'SdPayController@payNotify');
Route::any('sdpay_wallet_notify', 'SdPayController@walletNotify');

Route::middleware([
    \App\Http\Middleware\AgentGateway::class,
    \App\Http\Middleware\ApiResponse::class,
])->group(function () {
    // 图片上传（文件格式）
    Route::post('image_upload', 'CommonController@uploadImage');
    // 图片上传（Base64格式）
    Route::post('base64_image_upload', 'CommonController@uploadBase64Image');
    // 查询省市区信息
    Route::get('districts', 'CommonController@listDistricts');
    // 查询开户行列表
    Route::get('banks', 'CommonController@listBanks');
    // 查询配置信息
    Route::get('settings', 'CommonController@getAgentSettings');
    // 查询Banner列表
    Route::get('banners', 'CommonController@listBanners');
    // 订单支付测试
    Route::post('test_pay', 'OrderController@testPay');

    # 公告
    // 查询公告列表
    Route::get('notices', 'NoticeController@listNotices');
    // 查询公告详情
    Route::get('notices/{id}', 'NoticeController@getNotice');

    # 用户
    Route::post('verify_code', 'UserController@verifyCode');
    Route::post('user/register', 'UserController@register');
    Route::post('user/reset_password', 'UserController@resetPassword');
    Route::post('user/login', 'UserController@login');
    Route::post('user/fast_login', 'UserController@loginOrRegister');

    # 商品
    // 查询商品类别
    Route::get('product_categories', 'ProductController@listCategories');
    // 查询商品列表
    Route::get('products', 'ProductController@listProducts');
    // 查询发售日历
    Route::get('products/calendar', 'ProductController@getSaleCalendar');
    // 查询商品详情
    Route::get('products/{id}', 'ProductController@getProduct');
    // 查询商品存证
    Route::get('products/{id}/evidence', 'ProductController@getProductEvidence');
    // 查询资产存证
    Route::get('trans_evidence/{order_asset_id}', 'AssetController@getAssetEvidence');

    // 查询实物权益详情
    Route::get('rights_entities/{id}', 'RightsEntityController@getEntity');

    # 转售
    Route::get('resale_products', 'ResaleController@listResaleProducts');
    Route::get('resale_product_tokens', 'ResaleController@listResaleTokens');

    # 肓盒
    // 查询肓盒内的商品列表
    Route::get('blind_boxes/{id}/products', 'ProductController@listProductsInBlindBox');

    # 活动
    // 查询邀请排名
    Route::get('activity/{id}/invite/rankings', 'ActivityController@listInviteRankings');

    Route::middleware(['auth:' . \App\Constant::GUARD_API])->group(function () {
        # 用户
        // 查询用户信息
        Route::get('user/profile', 'UserController@getProfile');
        // 更新用户信息
        Route::post('user/profile', 'UserController@saveProfile');
        // 修改密码
        Route::post('user/change_password', 'UserController@changePassword');
        // 设置二级密码
        Route::post('user/second_pass', 'UserController@setSecondPassword');
        // 查询实名信息
        Route::get('user/real_name', 'UserController@getRealName');
        // 更新实名信息
        Route::post('user/real_name', 'UserController@saveRealName'); //已废弃
        // 身份证实名
        Route::post('user/id_card', 'UserController@saveIdCardImage');
        Route::post('user/id_card_manual', 'UserController@saveIdCard');
        // 银行卡绑定(更换）
        Route::post('user/bank_card', 'UserController@saveBankCard');
        // 查询地址信息
        Route::get('user/address', 'UserAddressController@getUserAddress');
        // 更新地址信息
        Route::post('user/address', 'UserAddressController@saveUserAddress');
        // 获取开通钱包的地址
        Route::get('user/wallet_url', 'UserController@getWalletUrl');

        # 订单
        // 创建订单
        Route::post('orders', 'OrderController@createOrder');
        // 查询订单列表
        Route::get('orders', 'OrderController@listMyOrders');
        // 订单详情
        Route::get('orders/{id}', 'OrderController@findOrder');
        // 订单详情
        Route::get('orders/{id}/assets', 'OrderController@listOrderAssets');
        // 取消订单
        Route::post('orders/{id}/cancel', 'OrderController@cancelOrder');
        // 删除订单
        Route::delete('orders/{id}', 'OrderController@deleteOrder');
        // 查询支付参数
        Route::get('orders/{id}/payment_params', 'OrderController@getPaymentParams');

        # 资产
        // 我的资产
        Route::get('assets', 'AssetController@listMyAssets');
        // 我的资产存证列表
        Route::get('asset_tokens', 'AssetController@listMyAssetTokens');
        // 获取权益
        Route::get('asset_key/{asset_id}', 'AssetController@listMyAssetKey');
        // 我的盲盒列表
        Route::get('my_blind_boxes', 'BlindBoxController@listMyBlindBoxes');
        // 开启盲盒
        Route::post('my_blind_boxes/{id}/open', 'BlindBoxController@openBlindBox');
        // 盲盒开启记录
        Route::get('my_blind_box_records', 'BlindBoxController@listBlindBoxOpenRecords');

        # 转售
        // 查询
        Route::get('resales/{asset_id}/prepare', 'ResaleController@prepareResale');
        // 发布转售商品（使用验证码）
        Route::post('resales', 'ResaleController@publishResaleWithVerifyCode');
        // 发布转售商品(使用二级密码）
        Route::post('resales_with_second_pass', 'ResaleController@publishResaleWithSecondPass');
        // 取消转售
        Route::post('resales/{product_id}/cancel', 'ResaleController@cancelResale');
        // 查询我的转售商品列表
        Route::get('resales', 'ResaleController@listMyResales');
        // 查询转售订单
        Route::get('resale_orders', 'ResaleController@listResaleOrders');
        // 查询转售订单详情
        Route::get('resale_orders/{order_id}', 'ResaleController@getResaleOrderDetail');

        # 转赠
        // 转赠商品(使用二级密码）
        Route::post('asset_give', 'AssetGiveController@assetGiveWithSecondPass');
        Route::get('asset_give', 'AssetGiveController@assetGiveList');

        # 合成
        // 查询可合成商品列表
        Route::get('converts', 'ConvertController@listFormulas');
        // 查询合成详情
        Route::get('converts/{id}', 'ConvertController@getFormula');
        // 合成
        Route::post('converts/{id}', 'ConvertController@convert');

        # 活动
        Route::get('activity/{id}/lottery', 'ActivityController@lotteryInfo');
        Route::post('activity/{id}/lottery/draw', 'ActivityController@draw');

        #邀请活动
        //邀请活动列表
        Route::get('invite_activities', 'InvitationActivityController@listInviteActivites');
        //邀请活动详情
        Route::get('invite_activities/{id}', 'InvitationActivityController@findInviteActivity');
        //邀请排名
        Route::get('invite_activities/{id}/ranking', 'InvitationActivityController@listInviteRankings');
        //我的邀请(全部数据)
        Route::get('invite_activities/{id}/my_invited', 'InvitationActivityController@listMyInvite');

        # 实物兑换
        // 确认兑换
        Route::post('entity_apply', 'RightsEntityController@exchanged');
        // 兑换记录
        Route::get('entity_apply_records', 'RightsEntityController@applyRecords');

        # 抽奖
        //查询当前进行中的活动
        Route::get('lotteries/current', 'LotteryController@getCurrentLottery');
        //抽奖
        Route::post('lotteries/{id}/draw', 'LotteryController@draw');
        //查询活动信息
        Route::get('lotteries/{id}', 'LotteryController@getLottery');
        //查询我的奖品
        Route::get('lottery_awards/my', 'LotteryController@listMyAwards');
        //查询奖品详情
        Route::get('lottery_awards/{id}', 'LotteryController@getAward');

        # 渠道
        Route::get('channels/{id}', 'ChannelController@getChannel');
        Route::get('channels/{id}/users', 'ChannelController@listChannelUsers');
        Route::get('channels/{id}/monthly_order_summaries', 'ChannelController@listOrderMonthSummaries');
        Route::get('channels/{id}/orders', 'ChannelController@listOrders');

        # Partner
        //禾只交易所用户自动注册
        Route::post('partner/hezhi_register', 'PartnerController@hezhiRegister');
    });
});
